"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Test = void 0;
const Config_1 = require("./src/config/Config");
const DbConfig_1 = require("./src/config/DbConfig");
const DateUtil_1 = require("./src/engine/utils/DateUtil");
const Logger_1 = require("./src/engine/utils/Logger");
const TimerUtil_1 = require("./src/engine/utils/TimerUtil");
// require("reflect-metadata")
require("reflect-metadata");
const jhaoproto_1 = require("./src/lib/net/protobuf/jhaoproto");
const ProtoManager_1 = require("./src/lib/net/protobuf/ProtoManager");
class Test {
    main() {
        return __awaiter(this, void 0, void 0, function* () {
            let port = parseInt(process.argv[2]);
            if (isNaN(port)) {
                Logger_1.Logger.error("port为空");
                return;
            }
            let environment = parseInt(process.argv[3]);
            if (isNaN(port)) {
                Logger_1.Logger.warn("environment为空");
                return;
            }
            Config_1.Config.environment = environment;
            if (Config_1.Config.environment == Config_1.Config.EnvironmentType.Online) {
                Logger_1.Logger.LEVEL = Logger_1.Logger.LOG_LEVEL_TYPES.LOG;
            }
            else {
                Logger_1.Logger.LEVEL = Logger_1.Logger.LOG_LEVEL_TYPES.DEBUG;
            }
            Config_1.Config.serverType = Config_1.Config.ServerType_List.log_server;
            Logger_1.Logger.tag = Config_1.Config.serverType + "-" + port;
            // DbConfig.init(DbConfig.Db_Type.Dev)
            DbConfig_1.DbConfig.init(DbConfig_1.DbConfig.Db_Type.Dev);
            TimerUtil_1.TimerUtil.init();
            // await ServerConfig.initConfig(port)
            // let user: UserEntity = new UserEntity()
            // user.account = "edddd"
            // let account: AccountEntity = new AccountEntity()
            // account.account = "ABCD✋ ✌ ☝ ✊ ✍ * ⛷ ⛹"
            // account.bundle_name = 'com.jhao.test'
            // account.create_time = DateUtil.formatDateStr(DateUtil.now())
            // let account2:AccountEntity = new AccountEntity()
            // account2.account = "abcd1"
            // await AccountDao.update_account(account)
            // let clubEntity:ClubEntity = new ClubEntity()
            // clubEntity.club_name = "abcd"
            // clubEntity.club_state = ClubConfig.Club_State_Type.Normal
            // clubEntity.clubid = 954146
            // clubEntity.create_time = DateUtil.formatDateStr(DateUtil.now())
            // clubEntity.creator = 124
            // clubEntity.notice = "aerer"
            // ClubDao.create_club(clubEntity)
            // AccountDao.get_account_info("swjlrlere")
            // await AccountDao.update_account(account2)
            //     let dataSource: DataSource = await DBSourceManager.instance.getDb(DbConfig.Db_Name.db_account);
            //    let accountRepository:Repository<AccountEntity> = dataSource.getRepository(AccountEntity)
            //    await accountRepository.save(account)
            //     // let fddd = await client.manager.find(AccountEntity)
            //     let fddd = await accountRepository.find()
            // photoRepository.remove()
            // Logger.log("fddd=====", fddd)
            // AccountDao.is_account_exist("ABCD")
            // AppDataSource.initialize().then(async () => {
            //     let dfdf = await AppDataSource.manager.save(user)
            //     Logger.log("save====",dfdf )
            //     // here you can start to work with your database
            // })
            //     .catch((error) => console.log(error))
            // UserDao.create_user("adfdfd", "* ✋ ✌ ☝ ✊ ✍ * ⛷ ⛹", 1, "http://132", "192.168.1.1")
            // UserDao.create_user("adfdfd", " ✋ ¥🔒", 1, "http://132", "192.168.1.1")
            // UserDao.create_user("adfdfd", "¥", 1, "http://132", "192.168.1.1")
            // UserDao.create_user("adfdfd", "🔒", 1, "http://132", "192.168.1.1")
            // AccountDao.is_ip_exist("192.168.1.1")
            // AccountDao.getAccountNum()
            // AccountDao.get_account_list(1, 10)
            // let isEmoji:boolean = IdentifiUtil.isEmojiCharacter("🤡🤡")
            // let isEmoji:boolean = IdentifiUtil.isEmojiCharacter("✊")
            // let isEmoji:boolean = IdentifiUtil.isEmojiCharacter("✌✌✌")
            // Logger.log("isEmojiCharacter=isEmoji=", isEmoji)
            // UserDao.
            // let result = await UserDao.get_user_data_by_account("adfdfd")
            // Logger.log("get_user_data_by_account==", result)
            // let user:UserEntity = new UserEntity()
            // user.userid = 100002
            // user.userid = null
            // user.account = "abcdeffg"
            // user.create_time = DateUtil.formatDateStr(DateUtil.now())
            // UserDao.update_user(user)
            let respData = {
                status: 1
            };
            Logger_1.Logger.log("server_internal_get_server_status", respData);
            let baseMsg = {
                cmdOrder: 1,
                cmdIndex: 1,
                timeDownload: DateUtil_1.default.now(),
            };
            baseMsg.data = ProtoManager_1.ProtoManager.instance.encode(jhaoproto_1.JhaoProto.resp_server_internal_get_server_status, respData);
            Logger_1.Logger.log("server_internal_get_server_statusbaseMsg", baseMsg);
            // let conn: SocketConnection = new SocketConnection(null, "127.0.0.1")
            // conn.createMsgToClient(1, 1, JhaoProto.resp_server_internal_get_serve6r_status, respData)
        });
    }
}
exports.Test = Test;
Test.instance = new Test();
Test.instance.main();
